<extend name="Public/base"/>

<block name="content">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
	<h3>广告管理</h3>
	<div class="panel panel-default">
		<div class="panel-heading"><if condition="$_GET['_action'] eq 'add'">新增<else/>编辑</if>广告</div>
		<div class="panel-body">
	<!-- 表单 -->
			<form id="form" action="<{:addons_url('Ads://Ads/update')}>" method="post" class="form-horizontal">
				<!-- 基础文档模型 -->
				<div id="tab1" class="tab-pane in tab1">
					<div class="form-group">
						<label class="col-sm-2 control-label">广告名称</label>
						<div class="col-sm-3">
							<input type="text" class="text form-control" name="title" value="<{$info.title}>">
						</div>
						<span class="check-tips">请输入广告显示名称</span>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">广告位置</label>
						<div class="col-sm-3">
				            <select name="position" id="mySelect" class="form-control">
				                  <option value="" data="">请选择位置</option>
				                  <volist name="sing" id="so">
				                  	<option value="<{$so.id}>" data="<{$so.type}>" <if condition="$so['id'] eq $info['position']">selected</if> ><{$so.title}></option>
				                  </volist>
				            </select>
						</div>
						<span class="check-tips">请选择广告位置,选择之后展开图片、文字、代码区域</span>
					</div>	
					
					<div class="form-group" id="type1" <if condition="($info['type'] neq 1) or ($info['type'] neq 2)">style="display:none;"</if>>
						<label class="col-sm-2 control-label">广告图片</label>
			            <div class="col-sm-3">
							<input type="file" id="upload_picture_advspic">
							<input type="hidden" name="advspic" id="cover_id_advspic" value="<{$info.advspic}>"/>
							<div class="upload-img-box">
								<notempty name="info['advspic']"><div class="upload-pre-item"><img src="__ROOT__<{$info.path}>"/></div></notempty>
							</div>
							<span class="check-tips">请上传广告图片</span>
						</div>
						<script type="text/javascript">
						//上传图片
					    /* 初始化上传插件 */
						$("#upload_picture_advspic").uploadify({
					        "height"          : 30,
					        "swf"             : "__STATIC__/uploadify/uploadify.swf",
					        "fileObjName"     : "download",
					        "buttonText"      : "上传图片",
					        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
					        "width"           : 120,
					        'removeTimeout'	  : 1,
					        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
					        "onUploadSuccess" : uploadPicture,
					        'onFallback' : function() {
					            alert('未检测到兼容版本的Flash.');
					        }
					    });
						function uploadPicture(file, data){
					    	var data = $.parseJSON(data);
					    	var src = '';
					        if(data.status){
					        	$("#cover_id_advspic").val(data.id);
					        	src = data.url || data.path
					        	$("#cover_id_advspic").parent().find('.upload-img-box').html(
					        		'<div class="upload-pre-item"><img src="__ROOT__' + src + '"/></div>'
					        	);
					        } else {
					        	updateAlert(data.info);
					        	setTimeout(function(){
					                $('#top-alert').find('button').click();
					                $(that).removeClass('disabled').prop('disabled',false);
					            },1500);
					        }
					    }
						</script>
					</div>	
					
					<div class="form-group" id="type3" <if condition="$info['type'] neq 3">style="display:none;"</if>>
						<label class="col-sm-2 control-label">广告文字</label>
			            <div class="col-sm-3">
							<textarea rows="3" cols="54" name="advstext"><{$info.advstext}></textarea>
						</div>
						<span class="check-tips">请填写广告文字</span>
					</div>				
						
					<div class="form-group" id="type4" <if condition="$info['type'] neq 4">style="display:none;"</if>>
						<label class="col-sm-2 control-label">广告代码</label>
			            <div class="col-sm-5">
		                    <textarea name="advshtml" style="width:100%"><{$info.advshtml}></textarea>
						</div>
						<span class="check-tips">请填写广告代码html、js</span>
					</div>						
									
					<!--div class="form-group">
						<label class="col-sm-2 control-label">外链地址</label>
						<div class="col-sm-3">
							<input type="text" class="text form-control" name="link" value="<{$info.link}>">
						</div>
						<span class="check-tips">请填写带http://的全路径</span>
					</div-->
					<div class="form-group">
						<label class="col-sm-2 control-label">开始时间</label>
						<div class="col-sm-3">
							<input type="text" name="create_time" class="text form-control time" value="<{$info.create_time}>" placeholder="请选择时间" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">结束时间</label>
						<div class="col-sm-3">
							<input type="text" name="end_time" class="text form-control time" value="<{$info.end_time}>" placeholder="请选择时间" />
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">优先级</label>
						<div class="col-sm-1">
							<input type="text" class="text form-control" name="level" value="<{$info.level}>">
						</div>
					</div>
				</div>
				<input type="hidden" name="id" value="<{$info.id}>"/>
				<div class="form-group">
					<div class="col-sm-4 col-sm-offset-2">
						<button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
						<input class="btn btn-return" type="reset" value="重置" />
					</div>
				</div>

			</form>
		</div>
	</div>
</block>

<block name="script">
<link href="__STATIC__/datetimepicker/css/datetimepicker.css" rel="stylesheet" type="text/css">
<php>if(C('COLOR_STYLE')=='blue_color') echo '<link href="__STATIC__/datetimepicker/css/datetimepicker_blue.css" rel="stylesheet" type="text/css">';</php>
<link href="__STATIC__/datetimepicker/css/dropdown.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript">
$(function(){
	$('#submit').click(function(){
		$('#form').submit();
	});	
	
	$('#mySelect').change(function(){
		$type = $('#mySelect').find("option:selected").attr("data");
		if($type == 1 || $type == 2){
			$('#type1').css('display','block');
		}else if($type == 3){
			$('#type3').css('display','block');
		}else if($type == 4){
			$('#type4').css('display','block');
		}else{
			$('#type1').css('display','none');
			$('#type3').css('display','none');
			$('#type4').css('display','none');
		}
	});
    /* 左边菜单高亮 */
    //var $subnav = $("#subnav");
    //url = {$current};
    //url = url.replace(/(\/(p)\/\d+)|(&p=\d+)|(\/(id)\/\d+)|(&id=\d+)|(\/(group)\/\d+)|(&group=\d+)/, "");
    //$subnav.find("a[href='" + url + "']").parent().addClass("current");	
	
    $('.time').datetimepicker({
        format: 'yyyy-mm-dd hh:ii',
        language:"zh-CN",
        minView:2,
        autoclose:true
    });
    //showTab();
});
</script>
</block>